
<template>
  <div class="app">
    <!-- 导航栏 -->
    <header>
      <meta  name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="description" content="安心陪诊服务平台提供全国各大医院全天、半天、诊前约号、预约挂号等陪诊服务，全程陪同就医服务，在陪诊前进行病情问询，协助院内预约挂号取号，陪同缴费就诊，取送化验结果，拿药，医嘱解读，让就医更高效，让家属更安心，患者更舒心。">
      <div class="container">
        <nav>
          <div class="logo">
            <a href="#">安心<span>陪诊</span></a>
          </div>
          <ul class="nav-links">
            <li><a href="#" class="active">首页</a></li>

            <li><a href="#" @click.prevent="goToServiceType">服务项目</a></li>

            <li><a href="#" @click.prevent="goToServiceProcess">服务流程</a></li>

            <li><a href="#" @click.prevent="goToNotice">公告中心</a></li>

            <li
                @mouseenter="showDropdown('about')"
                @mouseleave="hideDropdown()"
            >
              <a href="#">
                关于我们
                <el-icon><ArrowDown /></el-icon>
              </a>
              <ul
                  class="dropdown-menu"
                  v-if="activeDropdown === 'about'"
                  @mouseenter="cancelHide()"
                  @mouseleave="hideDropdown()"
              >
                <li><router-link to="/about">项目简介</router-link></li>
                <li><router-link to="/contact">联系我们</router-link></li>
              </ul>
            </li>
          </ul>
          <div class="nav-buttons">
            <button @click="goToLogin" class="btn">登录</button>
            <button @click="goToRegister" class="btn">注册</button>
          </div>
        </nav>
      </div>
    </header>
    <section class="hero">
      <div class="container">
        <h1>专业医院陪诊服务，让就医更轻松</h1>
        <p>我们提供专业的医院陪诊服务，帮助老人、孕妇、行动不便者等特殊群体解决就医难题，让您的就医过程更加安心、便捷。</p>
        <div class="hero-buttons">
          <a href="#" class="btn" @click.prevent="handleBookClick">立即预约</a>
          <a href="#" class="btn btn-secondary" @click.prevent="goToAbout">了解更多</a>
        </div>
      </div>
    </section>

    <!-- 服务特色 -->
    <section class="features">
      <div class="container">
        <div class="section-title">
          <h2>我们的服务特色</h2>
          <p>专业、贴心、可靠的医院陪诊服务，为您解决就医过程中的各种难题</p>
        </div>
        <div class="features-grid">
          <div class="feature-card" v-for="feature in features" :key="feature.title">
            <div class="feature-icon">{{ feature.icon }}</div>
            <h3>{{ feature.title }}</h3>
            <p>{{ feature.description }}</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 服务流程 -->
    <section class="process">
      <div class="container">
        <div class="section-title">
          <h2>服务流程</h2>
          <p>简单四步，轻松享受专业陪诊服务</p>
        </div>
        <div class="process-steps">
          <div class="step" v-for="step in processSteps" :key="step.number">
            <div class="step-number">{{ step.number }}</div>
            <h3>{{ step.title }}</h3>
            <p>{{ step.description }}</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 陪诊师展示 -->
    <section class="companions">
      <div class="container">
        <div class="section-title">
          <h2>专业陪诊师团队</h2>
          <p>我们的陪诊师均经过严格筛选和专业培训</p>
        </div>
        <div class="companions-grid">
          <div class="companion-card" v-for="companion in companions" :key="companion.id">
            <div class="companion-img" :style="{ backgroundImage: `url(${companion.image})` }"></div>
            <div class="companion-info">
              <h3>{{ companion.name }}</h3>
              <span class="companion-specialty">{{ companion.specialty }}</span>
              <div class="companion-rating">{{ companion.rating }}</div>
              <a href="#" class="btn">预约</a>
            </div>
          </div>
        </div>
      </div>
    </section>

    <!-- 联系我们 -->
    <section class="contact">
      <div class="container">
        <div class="section-title">
          <h2>联系我们</h2>
          <p>如有任何疑问，欢迎随时联系我们</p>
        </div>
        <div class="contact-container">
          <div class="contact-info">
            <h3>需要帮助？</h3>
            <div class="contact-details">
              <div class="contact-item">
                <div class="contact-icon">📞</div>
                <div>400-123-4567</div>
              </div>
              <div class="contact-item">
                <div class="contact-icon">✉️</div>
                <div>service@anxinpeizhen.com</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>

import {useRouter} from "vue-router";
import {ref} from "vue";
import {ElMessageBox} from "element-plus";


const router = useRouter();
const activeDropdown = ref(null);
const hoverTimeout = ref(null);// 当前激活的下拉菜单

const handleBookClick = () => {
  ElMessageBox({
    title: '提示',
    message: '<div style="text-align:center;padding:20px 0"><i class="el-icon-warning" style="color:#E6A23C;font-size:24px;margin-bottom:10px"></i><p style="margin:10px 0;font-size:16px">请先登录</p></div>',
    confirmButtonText: '立即登录',
    showCancelButton: true,
    cancelButtonText: '稍后再说',
    dangerouslyUseHTMLString: true,
    customClass: 'login-message-box',
  }).then(() => {
    router.push('/login');
  }).catch(() => {
    // 用户点击取消
  });
};

const dropdownOptions = {
  'about': [
    { name: '项目简介', path: '/about' },
    { name: '联系我们', path: '/contact' }
  ]
};


// 显示下拉菜单
const showDropdown = (menu) => {
  clearTimeout(hoverTimeout.value);
  activeDropdown.value = menu;
};

// 隐藏下拉菜单
const hideDropdown = () => {
  hoverTimeout.value = setTimeout(() => {
    activeDropdown.value = null;
  }, 200); // 200ms延迟
};

// 取消隐藏
const cancelHide = () => {
  clearTimeout(hoverTimeout.value);
};

// 切换下拉菜单（点击用）
// const toggleDropdown = (menu) => {
//   activeDropdown.value = activeDropdown.value === menu ? null : menu;
// };

const goToRegister = () => {
  router.push('/register')
};

const goToLogin = () => {
  router.push('/login')
};

const goToNotice = () => {
  router.push('/notice')
};

const goToServiceType = () => {
  router.push('/serviceType')
};

const goToAbout = () => {
  router.push('/about')
};

const goToServiceProcess = () => {
  router.push('/serviceProcess')
}

// 陪诊师数据
const companions = [
  {
    id: 1,
    name: '张晓晓',
    specialty: '三甲医院10年陪诊经验',
    rating: '★★★★★',
    image: '/imgs/escort/first1.png'
  },
  {
    id: 2,
    name: '李思源',
    specialty: '8年术后陪诊经验',
    rating: '★★★★☆',
    image: '/imgs/escort/first2.png'
  },
  {
    id: 3,
    name: '王琳琳',
    specialty: '老年护理专家',
    rating: '★★★★★',
    image: '/imgs/escort/first3.png'
  },
  {
    id: 4,
    name: '赵悠悠',
    specialty: '行动不便患者陪护',
    rating: '★★★★☆',
    image: '/imgs/escort/first4.png'
  }
]

// 服务特色数据
const features = [
  {
    icon: '👨‍⚕️',
    title: '专业陪诊师',
    description: '我们的陪诊师均经过专业培训，熟悉医院流程，能够提供专业的陪诊服务。'
  },
  {
    icon: '⏱️',
    title: '节省时间',
    description: '帮助您合理安排就医时间，避免长时间排队等待，提高就医效率。'
  },
  {
    icon: '❤️',
    title: '贴心服务',
    description: '全程陪护，协助办理各种手续，提供心理安慰，让您就医无忧。'
  }
]

// 服务流程数据
const processSteps = [
  {
    number: '1',
    title: '在线预约',
    description: '通过网站或电话预约陪诊服务'
  },
  {
    number: '2',
    title: '匹配陪诊师',
    description: '根据需求匹配最适合的陪诊师'
  },
  {
    number: '3',
    title: '确认服务',
    description: '确认服务细节和陪诊师信息'
  },
  {
    number: '4',
    title: '享受服务',
    description: '陪诊师按时到达提供专业服务'
  }
]
</script>

<style scoped>

.dropdown-arrow svg {
  width: 1em;
  height: 1em;
}

/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Microsoft YaHei', Arial, sans-serif;
}

body {
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  background-color: #4a90e2;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
  border: none;
  font-size: 16px;
}

.btn:hover {
  background-color: #3a7bc8;
}

.btn-secondary {
  background-color: #6c757d;
}

.btn-secondary:hover {
  background-color: #5a6268;
}

/* 导航栏 */
header {
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
}

.logo {
  font-size: 24px;
  font-weight: bold;
  color: #4a90e2;
}

.logo span {
  color: #333;
}

.nav-links {
  display: flex;
  gap: 30px;
}

.nav-links a {
  font-weight: 500;
  transition: color 0.3s;
}

.nav-links a:hover {
  color: #4a90e2;
}

.nav-links a.active {
  color: #4a90e2;
  font-weight: bold;
}

.nav-buttons {
  display: flex;
  gap: 15px;
}

/* 英雄区域 */
.hero {
  background: linear-gradient(135deg, #e3f2fd, #bbdefb);
  padding: 80px 0;
  text-align: center;
}

.hero h1 {
  font-size: 42px;
  margin-bottom: 20px;
  color: #2c3e50;
}

.hero p {
  font-size: 18px;
  max-width: 700px;
  margin: 0 auto 30px;
  color: #555;
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* 服务特色 */
.features {
  padding: 60px 0;
  background-color: white;
}

.section-title {
  text-align: center;
  margin-bottom: 50px;
}

.section-title h2 {
  font-size: 32px;
  color: #2c3e50;
  margin-bottom: 15px;
}

.section-title p {
  color: #777;
  max-width: 700px;
  margin: 0 auto;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.feature-card {
  background-color: #f8f9fa;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  transition: transform 0.3s, box-shadow 0.3s;
}

.feature-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.feature-icon {
  font-size: 48px;
  color: #4a90e2;
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 22px;
  margin-bottom: 15px;
  color: #2c3e50;
}

/* 服务流程 */
.process {
  padding: 60px 0;
  background-color: #f5f7fa;
}

.process-steps {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
  position: relative;
}

.process-steps::before {
  content: '';
  position: absolute;
  top: 30px;
  left: 0;
  right: 0;
  height: 3px;
  background-color: #4a90e2;
  z-index: 1;
}

.step {
  text-align: center;
  position: relative;
  z-index: 2;
  width: 20%;
}

.step-number {
  width: 60px;
  height: 60px;
  background-color: #4a90e2;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: bold;
  margin: 0 auto 15px;
}

.step h3 {
  margin-bottom: 10px;
  color: #2c3e50;
}

.step p {
  color: #666;
}

/* 陪诊师展示 */
.companions {
  padding: 60px 0;
  background-color: white;
}

.companions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
}

.companion-card {
  background-color: #f8f9fa;
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.3s;
}

.companion-card:hover {
  transform: translateY(-5px);
}

.companion-img {
  height: 200px;
  background-color: #ddd;
  background-size: cover;
  background-position: center;
}

.companion-info {
  padding: 20px;
}

.companion-info h3 {
  margin-bottom: 5px;
  color: #2c3e50;
}

.companion-specialty {
  color: #4a90e2;
  font-weight: 500;
  margin-bottom: 10px;
  display: block;
}

.companion-rating {
  color: #ffc107;
  margin-bottom: 15px;
}

/* 联系我们 */
.contact {
  padding: 60px 0;
  background-color: #f5f7fa;
}

.contact-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 50px;
  align-items: center;
}

.contact-info h3 {
  font-size: 24px;
  margin-bottom: 20px;
  color: #2c3e50;
}

.contact-details {
  margin-bottom: 30px;
}

.contact-item {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.contact-icon {
  margin-right: 15px;
  color: #4a90e2;
  font-size: 20px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }

  .hero h1 {
    font-size: 32px;
  }

  .hero-buttons {
    flex-direction: column;
    align-items: center;
  }

  .process-steps {
    flex-direction: column;
    align-items: center;
  }

  .process-steps::before {
    display: none;
  }

  .step {
    width: 100%;
    margin-bottom: 30px;
  }

  .contact-container {
    grid-template-columns: 1fr;
  }
}
/* 新增下拉菜单样式 */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  min-width: 160px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  padding: 10px 0;
  z-index: 1000;
}

.dropdown-menu li {
  padding: 8px 20px;
  transition: background-color 0.3s;
}

.dropdown-menu li:hover {
  background-color: #f5f7fa;
}

.dropdown-menu a {
  display: block;
  color: #333;
  white-space: nowrap;
}

.dropdown-menu a:hover {
  color: #4a90e2;
}

.nav-links > li {
  position: relative;
}

/* 响应式设计调整 */
@media (max-width: 768px) {
  .dropdown-menu {
    position: static;
    box-shadow: none;
    padding-left: 20px;
  }
}

</style>